package com.thesharegame.dal.util;

import java.lang.reflect.Method;

public class ObjectUtils {

	public static boolean hasID(Object object){
		try{
			Class<?> clazz = object.getClass();
			Method method = clazz.getMethod("getId", null);
			Object idObj = method.invoke(object, null);
			if(idObj instanceof Long){
				long id = ((Long)idObj).longValue();
				return id >= 0;
			}
		}catch(Exception e){
			return false;
		}
		return false;
	}
	
	public static boolean isPersistedObject(Object object){
		return hasID(object);
	}
}
